

#ifndef OGRAPHICSSYSTEM_H
#define OGRAPHICSSYSTEM_H

#include <QHash>
#include <QtGui/private/qgraphicssystem_p.h>
#include <QtGui/private/qgraphicssystemplugin_p.h>
#include "protocol.h"
#include <QtNetwork>

QT_BEGIN_NAMESPACE

class WindowSurface;
class OGraphicsSystem : public QObject, public QGraphicsSystem
{
    Q_OBJECT
public:
    OGraphicsSystem();

    QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
    QWindowSurface *createWindowSurface(QWidget *widget) const;

    bool connectToServer();
    bool sendRequest(const Request &request);
    bool waitForResponse(Response &response);

public slots:
    void eventDispatcher();

public:
    mutable QHash<quint32, WindowSurface*> m_surfaces;
    mutable QHash<QWidget*, quint32> m_ids;

private:
    QTcpSocket m_connection;
    Message m_message;


};

QT_END_NAMESPACE

#endif //OGRAPHICSSYSTEM_H
